#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
typedef char BTdatatype;
typedef struct Binarytreenode
{
	BTdatatype val;
	struct Binarytreenode* left;
	struct Binarytreenode* right;
}BTnode,*PBTnode;
PBTnode Createprebintree(BTdatatype*arr, int* pi)
{
	if (arr[*pi] == '#')
	{
		(*pi)++;
		return NULL;
	}
	PBTnode root = (PBTnode)malloc(sizeof(BTnode));
	root->val = arr[(*pi)++];
	root->left = Createprebintree(arr, pi);
	root->right = Createprebintree(arr, pi);
	return root;
}
void Inorder(PBTnode root)
{
	if (root == NULL)
	{
		return;
	}
	Inorder(root->left);
	printf("%c ", root->val);
	Inorder(root->right);
}
int main()
{
	char a[100];
	scanf("%s", a);
	int i = 0;
	PBTnode root = Createprebintree(a, &i);
	Inorder(root);
	return 0;
}